# coding:utf-8
import numpy as np
from sklearn.neighbors import KernelDensity
import pandas as pd
import pickle

data = pd.read_table("orders.tbl", sep='|')
sample = data.sample(frac=0.1)
o_totalprice = np.array(sample['o_totalprice'])
X = o_totalprice[:, np.newaxis]

kde = KernelDensity(kernel='gaussian', bandwidth=10).fit(X)

output = open('models/kde.pkl', 'wb')
pickle.dump(kde, output)
output.close()
